package com.qf.cx.simplenms.persist.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.qf.cx.simplenms.persist.dao.api.ReaderGroupDao;
import com.qf.cx.simplenms.persist.entity.ReaderGroupEntity;
import com.qf.cx.simplenms.persist.service.api.ReaderGroupService;

@Service
@Transactional(value = "hibernateTransactionManager")
public class ReaderGroupServiceImpl implements ReaderGroupService {
	@Autowired
	private ReaderGroupDao readerGroupDao;

	@Override
	public void addReaderGroup(ReaderGroupEntity readerGroup) {
		readerGroupDao.addReaderGroup(readerGroup);
	}

	@Override
	public void deleteReaderGroup(String name) {
		readerGroupDao.deleteReaderGroup(name);
	}

	@Override
	public void updateReaderGroup(ReaderGroupEntity readerGroup) {
		readerGroupDao.updateReaderGroup(readerGroup);
	}

	@Override
	public ReaderGroupEntity getReaderGroup(String name) {
		ReaderGroupEntity readerGroup = readerGroupDao.getReaderGroup(name);
		return readerGroup;
	}

	@Override
	public List<ReaderGroupEntity> getReaderGroups() {
		List<ReaderGroupEntity> list = readerGroupDao.getReaderGroups();
		return list;
	}

	@Override
	public void addReaderGroups(List<ReaderGroupEntity> readerGroups) {
		readerGroups.forEach(t -> readerGroupDao.addReaderGroup(t));
	}
}
